<%@ page import="java.sql.*"%>
<%@ page import="javax.sql.*"%>
<%@ page import="java.util.*"%>
<%@ page import="javax.naming.*"%>
<%@ page import="java.lang.*"%>
<%@ page contentType="text/html;charset=utf-8" %>

<html>
	<head><meta http-equiv="Content-Type" content="text/html;charset=utf-8">
		<title>Insert Check</title>		
	</head>
<%
	Connection conn=null;
	Context ctx=null;
	ResultSet rs=null;
	Statement stmt=null;
	try{
		//Hashtable ht=new Hashtable();
		//ht.put (Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
		//ht.put (Context.PROVIDER_URL, "t3://192.168.56.101:7011");
				
		Context initCtx = new InitialContext();
		Context envCtx = (Context)initCtx.lookup("java:/conf/env");
		DataSource ds=(DataSource)envCtx.lookup("test");	// JNDI
		conn=ds.getConnection(); //connection 

		stmt=conn.createStatement(); // SQL 문장 생성
		String sql="SELECT NO, STATE FROM TEST"; // SQL
		stmt.executeQuery(sql); // SQL 실행
		rs=stmt.getResultSet(); // ResultSet
%>
<body>
	<table border="1" cellpadding="0" cellspacing="1">
		<tr height="25" bgcolor="#E2EBF3">
			<td width="100" align="center"> No </td>
			<td width="100" align="center"> Result </td>
		</tr>
<%
	while(rs.next()) {
%>
		<tr height="25" >
			<td width="100" align="center"><%= rs.getString(1)%></td>
			<td width="100" align="center"><%= rs.getString(2)%></td>
		</tr>
<%
	}
	
	}catch(Exception e){
		System.out.println("Error "+ e.toString());
	}finally{
		if(rs != null)	rs.close();			// 반환
		if(stmt != null) stmt.close();		// 반환
		if(conn != null) conn.close();	// 반환
	}
%>
	</table>
</body>
</html>
